"""
将图片压缩至指定尺寸
"""
import os
import cv2
import time


if __name__ == '__main__':
    src_dir = 'raw'
    tar_dir = 'imgs'
    time_mark = time.strftime("%H%M%S", time.localtime(time.time()))
    file_list = os.listdir(src_dir)
    print(file_list)
    for filename in file_list:
        index = 0
        img_list = os.listdir(os.path.join(src_dir, filename))
        print(img_list)
        for img_name in img_list:
            img = cv2.imread(os.path.join(src_dir, filename, img_name))
            img = cv2.resize(img, (300, 300))
            cv2.imwrite(tar_dir + '/' + filename + '/' + time_mark + '_' + str(index) + '.jpg', img)
            index += 1
